{% extends 'index.html' %}
{% block body %}
<div class="row">
    <div class="alert alert-default col-sm-12" role="alert"><h4 style="display:inline;">Azienda: &nbsp;</h4> <h4 style="display:inline;"><strong>{{pageData["azienda"].denominazione}}</strong></h4></div>
     <div class="col-xs-12 col-md-12">
<div class="table">
  <table class="table  table-bordered table-striped table-condensed">
   <thead>
                <th>N.</th>
                <th>OPERAZIONE</th>
                <th>DATA</th>
                <th>RAGIONE SOCIALE</th>
                <th>P.IVA o C.F</th>
                <th>IMPON</th>
                <th>IMPOSTA</th>
                <th>TOTALE </th>
                <th>SOSPESO</th>
                <th>SALDATO</th>
                <th>RIF FORNI</th>
                <th>TIPO PAG</th>
                <th>BANCA</th>
    </thead>
      <tbody>
       {% for dao in pageData["objects"] %}
        {% set tota = dao.totali %}
    <tr>
        <td>{{dao.numero|string + ' ' + (dao.parte or '')|string}}</td>
        <td>{{dao.operazione}}</td>
        <td>{{utils.dateToString(dao.data_documento)}}</td>
        <td>{{dao.intestatario}}</td>
        <td>{{(dao.partita_iva_cliente or dao.codice_fiscale_cliente) if dao.id_cliente }}{{dao.partita_iva_fornitore if dao.id_fornitore }}</td>
        <td>{{utils.mNLC(dao._totaleImponibileScontato,2)}}</td>
        <td>{{utils.mNLC(dao._totaleImpostaScontata,2)}}</td>
        <td>{{utils.mNLC(dao._totaleScontato,2)}}</td>
            {% if dao.documento_saldato == True %}
                <td>{{utils.mNLC(0,2)}}</td>
                <td>{{utils.mNLC(dao._totaleScontato,2)}}</td>
            {% else %}
                    <td>{{utils.mNLC(dao.totale_sospeso,2)}}</td>
                    <td>{{utils.mNLC(dao.totale_pagato,2)}}</td>
            {% endif %}
        <td>{{dao.protocollo}}</td>
        <td>{{dao.pagamento}}</td>
        <td>{{dao.banca[0:20]}}</td>
    </tr>
        {% endfor %}
      </tbody>
      </table>
    </div>
         </div>
      <div class="clearfix"></div>
            {% set tot = utils.calcolaTotali(pageData["objects"]) %}
            {% for k, v in tot['cast_gen'].items() %}
        <div class="col-sm-4">
          <div class="panel panel-primary">
            <div class="panel-heading">
              <h5 class="panel-title">Aliquota {{ utils.mN(k, 0) }}%</h5>
            </div>
            <div class="panel-body">
                <div class="col-sm-12"><span class="label label-primary">IMPONIBILE</span> {{utils.mNLC(v[0], 2)}}</div>
                <div class="col-sm-12"><span class="label label-primary">IMPOSTA</span> {{utils.mNLC(v[1], 2)}}</div>
            </div>
          </div>
  </div>
                {% endfor %}
        <div class="col-xs-12 col-md-12">
                       <div class="col-sm-6">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h5 class="panel-title">TOTALI NON SCONTATI</h5>
            </div>
            <div class="panel-body">
                <div class="col-sm-12"><span class="label label-default">IMPONIBILE</span> {{utils.mNLC(tot["totale_imponibile_non_scontato"],2)}}</div>
                <div class="col-sm-12"><span class="label label-default">IMPOSTA</span> {{utils.mNLC(tot["totale_imposta_non_scontata"],2)}}</div>
                                <div class="col-sm-12"><span class="label label-default">GENERALE</span> {{utils.mNLC(tot["totale_non_scontato"],2)}}</div>
            </div>
          </div>
  </div>
    <div class="col-sm-6">
          <div class="panel panel-warning">
            <div class="panel-heading">
              <h5 class="panel-title">TOTALE SCONTI</h5>
            </div>
            <div class="panel-body">
                <div class="col-sm-12"><span class="label label-warning">IMPONIBILE</span> {{utils.mNLC(tot["totale_imponibile_non_scontato"]-tot["totale_imponibile_scontato"],2)}}</div>
                <div class="col-sm-12"><span class="label label-warning">IMPOSTA</span> {{utils.mNLC(tot["totale_imposta_non_scontata"]-tot["totale_imposta_scontata"],2)}}</div>
                                <div class="col-sm-12"><span class="label label-warning">GENERALE</span> {{utils.mNLC(tot["totale_non_scontato"]-tot["totale_scontato"],2)}}</div>
            </div>
          </div>
  </div>
    <div class="col-sm-6">
          <div class="panel panel-danger">
            <div class="panel-heading">
              <h4 class="panel-title">TOTALE SCONTATO</h4>
            </div>
            <div class="panel-body">
                <div class="col-sm-12"><span class="label label-danger">IMPONIBILE</span> {{utils.mNLC(tot["totale_imponibile_scontato"],2)}}</div>
                <div class="col-sm-12"><span class="label label-danger">IMPOSTA</span> {{utils.mNLC(tot["totale_imposta_scontata"],2)}}</div>
                                <div class="col-sm-12"><span class="label label-danger">GENERALE</span> {{utils.mNLC(tot["totale_scontato"],2)}}</div>
            </div>
          </div>
  </div>
<div class="col-sm-6"><span class="label label-info">SOSPESO</span> {{utils.mNLC(tot["totale_sospeso"],2)}}</div>
<div class="col-sm-6"><span class="label label-success">PAGATO</span> {{utils.mNLC(tot["totale_pagato"],2)}}</div>
         </div>
</div>

{% endblock %}
